﻿/* 
 * TABLE: dbo.Favorites 
 */

/* 
 * TABLE: Favorites 
 */

CREATE TABLE Favorites(
    BookId    int    NOT NULL,
    IsRead    bit    CONSTRAINT [IsRead] DEFAULT 0 NOT NULL,
    UserId    int    NOT NULL,
    CONSTRAINT PK_Favorites PRIMARY KEY NONCLUSTERED (BookId, UserId)
)
GO
ALTER TABLE Favorites ADD CONSTRAINT FKUsers_Favorites 
    FOREIGN KEY (UserId)
    REFERENCES Users(UserId)
GO
/* 
 * TABLE: dbo.Favorites 
 */

/* 
 * TABLE: Favorites 
 */

ALTER TABLE Favorites ADD CONSTRAINT FKBooks_Favorites 
    FOREIGN KEY (BookId)
    REFERENCES Books(BookId)